package chapter8;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2018-03-20 上午9:08
 */
public class ColorC {
    private String title;
    private static final ColorC RED = new ColorC("红色");
    private static final ColorC GREEN = new ColorC("绿色");
    private static final ColorC BLUE = new ColorC("蓝色");

    public static ColorC getInstance(int ch) {
        switch (ch) {
            case 1:
                return RED;
            case 2:
                return GREEN;
            case 3:
                return BLUE;
            default:
                return null;
        }
    }

    private ColorC(String title) {
        this.title = title;
    }

    @Override
    public String toString() {
        return this.title;
    }
}
